package com.ruoyi.web.controller.organizers.admin;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.activity.service.IWebOrganizersService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.model.organizers.WebOrganizers;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 主办方Controller
 *
 * @author 张怀秋
 * &#064;date  2024-08-02
 */
@RestController
@RequestMapping("/admin/organizers/organizers")
public class WebOrganizersController extends BaseController {

    @Autowired
    private IWebOrganizersService webOrganizersService;

    /**
     * 查询主办方列表
     */
    @PreAuthorize("@ss.hasPermi('organizers:organizers:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebOrganizers webOrganizers) {
        startPage();
        List<WebOrganizers> list = webOrganizersService.selectWebOrganizersList(webOrganizers);
        return getDataTable(list);
    }

    /**
     * 导出主办方列表
     */
    @PreAuthorize("@ss.hasPermi('organizers:organizers:export')")
    @Log(title = "主办方", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WebOrganizers webOrganizers) {
        List<WebOrganizers> list = webOrganizersService.selectWebOrganizersList(webOrganizers);
        ExcelUtil<WebOrganizers> util = new ExcelUtil<WebOrganizers>(WebOrganizers.class);
        util.exportExcel(response, list, "主办方数据");
    }

    /**
     * 获取主办方详细信息
     */
    @PreAuthorize("@ss.hasPermi('organizers:organizers:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(webOrganizersService.selectWebOrganizersById(id));
    }

    /**
     * 新增主办方
     */
    @PreAuthorize("@ss.hasPermi('organizers:organizers:add')")
    @Log(title = "主办方", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebOrganizers webOrganizers) {
        return toAjax(webOrganizersService.insertWebOrganizers(webOrganizers));
    }

    /**
     * 修改主办方
     */
    @PreAuthorize("@ss.hasPermi('organizers:organizers:edit')")
    @Log(title = "主办方", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebOrganizers webOrganizers) {
        return toAjax(webOrganizersService.updateWebOrganizers(webOrganizers));
    }

    /**
     * 删除主办方
     */
    @PreAuthorize("@ss.hasPermi('organizers:organizers:remove')")
    @Log(title = "主办方", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(webOrganizersService.deleteWebOrganizersByIds(ids));
    }
}
